package ${packageName}.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bjxczy.core.feign.client.user.BaseTenantUserFeignClient;
import com.bjxczy.onepark.common.context.LoginTenantUserContextHolder;
import com.bjxczy.onepark.common.context.TenantContextHolder;
import com.bjxczy.onepark.common.model.common.TenantInfo;
import com.bjxczy.onepark.common.model.user.TenantUserInformation;
import ${packageName}.pojo.dto.${upperDataKey}AddRequest;
import ${packageName}.pojo.dto.${upperDataKey}EditRequest;
import ${packageName}.pojo.dto.${upperDataKey}QueryRequest;
import ${packageName}.pojo.vo.${upperDataKey}VO;
import ${packageName}.service.${upperDataKey}Service;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;


/**
 * ${dataName}单元测试
 *
 */

@SpringBootTest
class ${upperDataKey}ServiceImplTest {

    public static final String TENANT_ID = "78be7dbceed560b1b9a26336fe384b70";

    public static final Integer LOGIN_USER_ID = 90;
    @Resource
    private BaseTenantUserFeignClient tenantUserFeignClient;
    @Resource
    private ${upperDataKey}Service ${dataKey}Service;

    /**
    * 新增${dataName}
    */
    @Test
    public void add(){
        buildCommonParams();
        ${upperDataKey}AddRequest ${dataKey}AddRequest = new ${upperDataKey}AddRequest();
        ${dataKey}Service.add(${dataKey}AddRequest);
    }

    /**
    * 编辑${dataName}
    */
    @Test
    public void edit(){
        buildCommonParams();
        ${upperDataKey}EditRequest ${dataKey}EditRequest = new ${upperDataKey}EditRequest();
        ${dataKey}Service.edit(${dataKey}EditRequest);
    }

    /**
     * 分页获取${dataName}列表
     */
    @Test
    public void selPage(){
        buildCommonParams();
        ${upperDataKey}QueryRequest ${dataKey}QueryRequest = new ${upperDataKey}QueryRequest();
        IPage<${upperDataKey}VO> vo = ${dataKey}Service.selPage(${dataKey}QueryRequest);
        System.out.println(vo.getRecords());
    }

    /**
     * 删除${dataName}
     */
    @Test
    public void delById(){
        buildCommonParams();
        String id = "";
        ${dataKey}Service.delById(id);
    }

    /**
    * 公共参数
    */
    private void buildCommonParams() {
        TenantContextHolder.set(new TenantInfo(TENANT_ID));
        TenantUserInformation user = tenantUserFeignClient.findById(LOGIN_USER_ID);
        LoginTenantUserContextHolder.set(user);
    }
}
